home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / MISC / DTMFF110 / GR_DOS.C < prev    next >
C/C++ Source or Header  |  1997-06-09  |  3KB  |  146 lines

  1. /*
  2.  * Graphics function remaps for Borland's BGI drivers
  3.  * Time function (returns string)
  4.  * Copyright (C) 1995  Philip VanBaren
  5.  */
  6. #include <stdio.h>
  7. #include <dos.h>
  8. #include <conio.h>
  9. #include <graphics.h>
  10. #include <string.h>
  11.  
  12. #include "freq.h"
  13. #include "display.h"
  14.  
  15. int          _font_color;
  16. int          _font_width;
  17. int          _font_height;
  18.  
  19. extern int    done;
  20.  
  21. char          time_str[20];
  22.  
  23. char         *
  24. time_stamp( void )
  25. {
  26.   struct time    ts;
  27.   struct date    ds;
  28.  
  29.   gettime( &ts );
  30.   getdate( &ds );
  31.   sprintf( time_str, "%2d-%02d-%02d  %02d:%02d:%02d",
  32.   ds.da_day, ds.da_mon, ds.da_year % 100, ts.ti_hour, ts.ti_min, ts.ti_sec );
  33.   return time_str;
  34. }
  35.  
  36. int
  37. ctrlcfunc( void )
  38. {
  39.   /* Function called whenever Ctrl-C is pressed (Borland C only) */
  40.   done = 1;
  41.   return 1;
  42. }
  43.  
  44. void
  45. setup_graphics( void )
  46. {
  47.   int        gdriver = VGA, gmode = VGAHI;
  48.   registerbgidriver( EGAVGA_driver );
  49.   initgraph( &gdriver, &gmode, "" );
  50.   setlinestyle( SOLID_LINE, 0, 1 );
  51.   settextjustify( LEFT_TEXT, TOP_TEXT );
  52.   settextstyle( DEFAULT_FONT, HORIZ_DIR, 1 );
  53.   _font_height = 8;
  54.   _font_width = 8;
  55.   _font_color = TEXT_COLOR;
  56. }
  57.  
  58. void
  59. draw_text_left( int x, int y, char *string )
  60. {
  61.   setcolor( _font_color );
  62.   outtextxy( x, y, string );
  63. }
  64.  
  65. void
  66. draw_text_centered( int x, int y, char *string )
  67. {
  68.   setcolor( _font_color );
  69.   outtextxy( x - strlen( string ) * _font_width / 2, y, string );
  70. }
  71.  
  72. void
  73. draw_text_right( int x, int y, char *string )
  74. {
  75.   setcolor( _font_color );
  76.   outtextxy( x - strlen( string ) * _font_width, y, string );
  77. }
  78.  
  79. void
  80. draw_text_vertical( int x, int y, char *string )
  81. {
  82.   settextstyle( DEFAULT_FONT, VERT_DIR, 1 );
  83.   setcolor( _font_color );
  84.   outtextxy( ( x ) + _font_width, y, string );
  85.   settextstyle( DEFAULT_FONT, HORIZ_DIR, 1 );
  86. }
  87.  
  88. void
  89. draw_fontcolor( int c )
  90. {
  91.   _font_color = c;
  92. }
  93.  
  94. void
  95. draw_rectangle( int x1, int y1, int x2, int y2, int c )
  96. {
  97.   setcolor( c );
  98.   rectangle( x1, y1, x2, y2 );
  99. }
  100.  
  101. void
  102. draw_line( int x1, int y1, int x2, int y2, int c )
  103. {
  104.   setcolor( c );
  105.   moveto( x1, y1 );
  106.   lineto( x2, y2 );
  107. }
  108.  
  109. void
  110. draw_bar( int x1, int y1, int x2, int y2, int c )
  111. {
  112.   setfillstyle( SOLID_FILL, c );
  113.   bar( x1, y1, x2, y2 );
  114. }
  115.  
  116. void
  117. draw_setpalatte( int n, int r, int g, int b )
  118. {
  119.   setrgbpalette( n, r, g, b );
  120. }
  121.  
  122. int
  123. draw_getch(  )
  124. {
  125.   register int    c = getch(  );
  126.   if ( c > 0 )
  127.     return ( c );
  128.   else
  129.     return ( 0x100 + getch(  ) );
  130. }
  131.  
  132. int
  133. draw_getkey(  )
  134. {
  135.   if ( kbhit(  ) )
  136.   {
  137.     register int  c = getch(  );
  138.     if ( c > 0 )
  139.       return ( c );
  140.     else
  141.       return ( 0x100 + getch(  ) );
  142.   }
  143.   else
  144.     return ( 0 );
  145. }
  146.